VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "ball"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Dim PrivateFrm As ballfrm
Dim x As Long, y As Long
Dim velx As Long, vely As Long

Private Sub Class_Initialize()
    Set PrivateFrm = New ballfrm
    PrivateFrm.Show
End Sub

Private Sub Class_Terminate()
    Unload PrivateFrm
End Sub

Public Sub SetXYVel(nxv As Long, nyv As Long)
    velx = nxv
    vely = nyv
End Sub

Public Sub SetXY(nx As Long, ny As Long)
    x = nx
    y = ny
End Sub

Public Sub GetXYVel(xv As Long, yv As Long)
    xv = velx
    yv = vely
End Sub

Public Sub GetXY(xv As Long, yv As Long)
    xv = x
    yv = y
End Sub

Public Sub Move()
    x = x + velx
    y = y + vely
    
    If x < 0 Then x = 0: velx = Not velx
    If x > (GetSystemMetrics(SM_CXSCREEN) - PrivateFrm.ScaleWidth) Then x = (GetSystemMetrics(SM_CXSCREEN) - PrivateFrm.ScaleWidth): velx = Not velx
    If y < 0 Then y = 0: vely = Not vely
    If y > (GetSystemMetrics(SM_CYSCREEN) - PrivateFrm.ScaleHeight) Then y = (GetSystemMetrics(SM_CYSCREEN) - PrivateFrm.ScaleHeight): vely = Not vely
End Sub

Public Sub Update()
    SetWindowPos PrivateFrm.hWnd, HWND_TOPMOST, x, y, 0, 0, SWP_NOSIZE
End Sub

Public Sub xit()
    Call Class_Terminate
End Sub
